import { View } from "../../../../../mvc/core/View";
import { LayerManager } from "../../../../manager/LayerManager";
import { Global } from "../../../../../../com/gengine/global/Global";
import { ObjCreate } from "../../../common/ObjCreate";
import { ImagesConst } from "../../../../resource/ImagesConst";
import { GTextFormat } from "../../../../../common/GTextFormat";
import { FontUtil } from "../../../../../common/font/FontUtil";
import { GlobalStyle } from "../../../../../common/global/GlobalStyle";
import { LoaderHelp } from "../../../../../common/display/LoaderHelp";
import { ResFileConst } from "../../../../resource/ResFileConst";
import { MsgManager } from "../../../../manager/MsgManager";
import { Language } from "../../../../../../extend/language/Language";
import { Dispatcher } from "../../../../../mvc/core/Dispatcher";
import { DataEvent } from "../../../../events/DataEvent";
import { EventName } from "../../../../mvc/EventName";
import { GlobalClass } from "../../../../../../com/mui/core/GlobalClass";
import { SArenaCrossFlowerNum } from "../../../../../../Message/Public/SArenaCrossFlowerNum";
import { EntityUtil } from "../../../../scene/layer/utils/EntityUtil";
import { SArenaCrossBattleInfo } from "../../../../../../Message/Public/SArenaCrossBattleInfo";
import { GButton } from "../../../../../../com/mui/controls/GButton";
//class LittleSendFlower
    
    export  class LittleSendFlower extends View
    {
        constructor()
        {
            super();
            this.layer = LayerManager.uiLayer;
            this.initView();
            this.resize();
            return;
        }

        public resize(): void
        {
            this.x = Global.stage.stageWidth * 0.5;
            this.y = 15;
            return;
        }

        /* internal  */initView(): void
        {
            ObjCreate.createBg(0, 0, 285, 84, this, ImagesConst.ToolTipBg);
            ObjCreate.createBitmap(ImagesConst.ArenaVS, 120, 22, this);
            this._plusBtn = ObjCreate.createGButton("", 256, 5, 19, 19, this, "PlusBtn");
            this._plusBtn.addEventListener(flash.events.MouseEvent.CLICK, this.onPlusBtnClickHandler);
            this._oneServerTx = ObjCreate.createTextField("", 44, 15, 64, 20, this, new GTextFormat(FontUtil.songtiName, 12, 65535));
            this._twoServerTx = ObjCreate.createTextField("", 188, 15, 64, 20, this, new GTextFormat(FontUtil.songtiName, 12, 65535));
            this._oneNameTx = ObjCreate.createTextField("", 26, 32, 80, 20, this, new GTextFormat(FontUtil.songtiName, 12, 11661311, null, null, null, null, null, flash.text.TextFormatAlign.CENTER));
            this._twoNameTx = ObjCreate.createTextField("", 168, 32, 80, 20, this, new GTextFormat(FontUtil.songtiName, 12, 11661311, null, null, null, null, null, flash.text.TextFormatAlign.CENTER));
            this._stFlowerBmI = ObjCreate.createBitmap("", 32, 53, this);
            this._stFlowerBmII = ObjCreate.createBitmap("", 175, 53, this);
            this._oneFlowerNumTx = ObjCreate.createTextField("", 77, 51, 46, 22, this, new GTextFormat(FontUtil.stXingkaiName, 20, GlobalStyle.color5Uint));
            this._twoFlowerNumTx = ObjCreate.createTextField("", 220, 51, 46, 22, this, new GTextFormat(FontUtil.stXingkaiName, 20, GlobalStyle.color5Uint));
            LoaderHelp.addResCallBack(ResFileConst.ArenaCrossGroupSendFlowers, this.onLoadBmResource);
            return;
        }

        protected onPlusBtnClickHandler(arg1: Object /* flash.events.MouseEvent */): void
        {
            if (this._sArenaCrossBattleInfo) 
            {
                if (this._sArenaCrossBattleInfo.hadSendFlower) 
                {
                    MsgManager.showRollTipsMsg(Language.getString(42293));
                    return;
                }
            }
            Dispatcher.dispatchEvent(new DataEvent(EventName.ArenaCrossGroupShowBigSendFlower));
            this.hide();
            return;
        }

        /* internal  */onLoadBmResource(): void
        {
            this._stFlowerBmI.bitmapData = GlobalClass.getBitmapData(ImagesConst.ArenaCrossSFFlowers);
            this._stFlowerBmII.bitmapData = GlobalClass.getBitmapData(ImagesConst.ArenaCrossSFFlowers);
            return;
        }

        public updatInfo(arg1: SArenaCrossFlowerNum): void
        {
            var loc1=null;
            var loc2=null;
            var loc3=null;
            if (this._sArenaCrossBattleInfo) 
            {
                loc1 = EntityUtil.toString(arg1.entityId);
                loc2 = EntityUtil.toString(this._sArenaCrossBattleInfo.miniPlayerOne.entityId);
                loc3 = EntityUtil.toString(this._sArenaCrossBattleInfo.miniPlayerTwo.entityId);
                if (loc1 != loc2) 
                {
                    if (loc1 == loc3) 
                    {
                        this._twoFlowerNumTx.text = arg1.flowerNum.toString();
                    }
                }
                else 
                {
                    this._oneFlowerNumTx.text = arg1.flowerNum.toString();
                }
            }
            return;
        }

        public updateBattleInfo(arg1: SArenaCrossBattleInfo): void
        {
            this._sArenaCrossBattleInfo = arg1;
            this._oneNameTx.text = arg1.miniPlayerOne.name;
            this._twoNameTx.text = arg1.miniPlayerTwo.name;
            this._oneServerTx.text = EntityUtil.getProxyName(arg1.miniPlayerOne.entityId);
            this._twoServerTx.text = EntityUtil.getProxyName(arg1.miniPlayerTwo.entityId);
            this._oneFlowerNumTx.text = arg1.flowerNumOne.toString();
            this._twoFlowerNumTx.text = arg1.flowerNumTwo.toString();
            return;
        }

        /* internal */ /* var */_plusBtn: GButton;

        /* internal */ /* var */_oneServerTx: Object /* flash.text.TextField */;

        /* internal */ /* var */_twoServerTx: Object /* flash.text.TextField */;

        /* internal */ /* var */_oneNameTx: Object /* flash.text.TextField */;

        /* internal */ /* var */_twoNameTx: Object /* flash.text.TextField */;

        /* internal */ /* var */_stFlowerBmI: Object /* flash.display.Bitmap */;

        /* internal */ /* var */_stFlowerBmII: Object /* flash.display.Bitmap */;

        /* internal */ /* var */_oneFlowerNumTx: Object /* flash.text.TextField */;

        /* internal */ /* var */_twoFlowerNumTx: Object /* flash.text.TextField */;

        /* internal */ /* var */_sArenaCrossBattleInfo: SArenaCrossBattleInfo;
    }
